//
//  DeviceManagerTableViewCell.m
//  CityFire
//
//  Created by liuyangzhu on 2017/8/3.
//  Copyright © 2017年 刘养柱. All rights reserved.
//

#import "DeviceManagerTableViewCell.h"

@implementation DeviceManagerTableViewCell

- (NSString*)showStatusString:(NSString*)status {
    NSString *statusStr = @"";
    if ([status isEqualToString:@"01"]) {
        statusStr = @"正常";
    }else if ([status isEqualToString:@"03"]) {
        statusStr = @"报警";
    }else if ([status isEqualToString:@"02"]) {
        statusStr = @"故障";
    }else if ([status isEqualToString:@"04"]) {
        statusStr = @"异常";
    }else if ([status isEqualToString:@"05"]) {
        statusStr = @"离线";
    }
    return statusStr;
}

- (UIColor*)showStatusLblColor:(NSString*)status {
    UIColor *statusLblColor = [UIColor orangeColor];
    if ([status isEqualToString:@"01"]) {
        statusLblColor = [UIColor orangeColor];
    }else if ([status isEqualToString:@"02"]) {
        statusLblColor = [UIColor redColor];
    }else if ([status isEqualToString:@"03"]) {
        statusLblColor = [UIColor orangeColor];
    }else if ([status isEqualToString:@"04"]) {
        statusLblColor = [UIColor greenColor];
    }else if ([status isEqualToString:@"05"]) {
        statusLblColor = [UIColor blackColor];
    }
    return statusLblColor;
}
- (void)setMonitorModel:(MonitorModel *)monitorModel
{
    self.deviceNameLabel.text = [NSString stringWithFormat:@"设备名称：%@", monitorModel.deviceName1];
    self.deviceCodeLabel.text = [NSString stringWithFormat:@"设备编号:%ld", monitorModel.deviceCode1];
    //    [UIColor colorWithRed: / 255.0 green:/ 255.0 blue: / 255.0 alpha:1.0f]
    self.statusLabel.text = [self showStatusString:monitorModel.status1];
    self.statusLabel.textColor = [self showStatusLblColor:monitorModel.status1];
    self.companyNameLabel.text = [NSString stringWithFormat:@"%@", monitorModel.deviceOrg];
    self.addressLabel.text = [NSString stringWithFormat:@"%@", monitorModel.deviceAddress1];
    self.deviceTypeLabel.text = [NSString stringWithFormat:@"设备类型：%@", monitorModel.deviceType1];
    self.phoneLabel.text = [NSString stringWithFormat:@"联系电话：%@", monitorModel.phone];
    self.markLabel.text = [NSString stringWithFormat:@"备注：%@", monitorModel.remark];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
